import { createRouter, createWebHistory } from 'vue-router'
import MainLayout from '@/components/layout/MainLayout.vue'
import Login from '@/views/Public/Login.vue'
import ScoreQuery from '@/views/Public/ScoreQuery.vue'

// 懒加载其它页面
const TeamRegister = () => import('@/views/Student/TeamRegister.vue')
const UploadWork = () => import('@/views/Student/UploadWork.vue')
const DownloadTopic = () => import('@/views/Student/DownloadTopic.vue')
const PreviewAndScore = () => import('@/views/Teacher/PreviewScore.vue')
const TeacherHome = () => import('@/views/Teacher/TeacherHome.vue')
const AdminLogin = () => import('@/views/Admin/AdminLogin.vue')
const CreateContest = () => import('@/views/Admin/CreateContest.vue')

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/score-query',
    name: 'ScoreQuery',
    component: ScoreQuery
  },
  {
    path: '/admin/login',
    name: 'AdminLogin',
    component: AdminLogin
  },
  {
    path: '/',
    component: MainLayout,
    children: [
      // 学生相关
      {
        path: '/student/team-register',
        name: 'TeamRegister',
        component: TeamRegister
      },
      {
        path: '/student/upload-work',
        name: 'UploadWork',
        component: UploadWork
      },
      {
        path: '/student/download-topic',
        name: 'DownloadTopic',
        component: DownloadTopic
      },
      // 教师相关
      {
        path: '/teacher/preview-score',
        name: 'PreviewAndScore',
        component: PreviewAndScore
      },
      {
        path: '/teacher/home',
        name: 'TeacherHome',
        component: TeacherHome
      },
      // 管理员相关
      {
        path: 'admin/create-contest',
        name: 'CreateContest',
        component: CreateContest
      }
      // 你可以继续添加其它需要布局的页面
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
